package mytest.leetcode;

public class P189 {

    public static void main(String[] args) {
        int k = 2;
        int[] nums = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
        int n = nums.length;
        int[] newArray = new int[n];
        for (int i = 0; i < n; i++) {
            newArray[(i + k) % n] = nums[i];
        }
        System.arraycopy(newArray, 0, nums, 0, n);
        for (int i = 0; i < n; i++) {
            System.out.print(nums[i] + " ");
        }
    }
}
